/**
  ******************************************************************************
  * @file    main_task.h
  * @brief
  * @author  zp
  * @version V1.0.0
  * @date    2022/02/15
  ******************************************************************************
  */

#ifndef __BACKFILL_H__
#define __BACKFILL_H__

/* Includes ------------------------------------------------------------------*/

/* Bsp includes. */
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include "FreeRTOS.h"
#include "task.h"
#include "dev_time.h"
#include "main_task.h"
/* Os includes. */

/* User includes. */


/* Public macro --------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private Enum --------------------------------------------------------------*/
typedef enum{
	BSM_BALANCE,
	BSM_FILL,
	BSM_MOTOR_REVERSE,
	BSM_CALIBRATE,
	BSM_IDLE,
	BSM_NONE,
	
}BackfillStateMachine_e;

typedef enum{
	IPSM_ENTRY,
	IPSM_CAL,
	IPSM_EXEC,
	IPSM_HYSTER,
	IPSM_FINISH,
	IPSM_NONE,
}InfPunmpStateMachine_e;


typedef struct 
{
    float initial_pressure;
    float final_pressure;
    float flow_rate;
    float opening;
} Inf_Pum_Record;

typedef struct
{
    Inf_Pum_Record *records;
    uint8_t *record_count;
	float gas_min_open;
} RecordContext;


/* Private Union -------------------------------------------------------------*/


/* Type defines --------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/
extern DataServer_t data_server;
extern MainStateMachine_e msm;
extern RunStateMachine_e rsm;
extern volatile bool isPressMutexReleased ;
extern TaskHandle_t MonitorTask_Handler;
extern bool isBackFillFlag;
extern uint8_t record_pos;

/* Private Struct ------------------------------------------------------------*/

/* Pubilc function prototypes ------------------------------------------------*/

void Back_Fill_Task(void *pvParameters);

#endif // __MAINTASK_H__


